﻿using System;

namespace Abide_AddOn_API.Interfaces
{
    public interface IAddOnHost
    {
        /// <summary>
        /// Gets a value indicating whether the caller must call an invoke method when
        /// making method calls to the host control because the caller is on a different
        /// thread than the one the host control was created on.
        /// </summary>
        bool InvokeRequired
        {
            get;
        }

        /// <summary>
        /// Sends a command to the AddOn Host.
        /// </summary>
        /// <param name="sender">The client AddOn</param>
        /// <param name="command">The Command String</param>
        /// <param name="args">Extra arguements.</param>
        /// <returns></returns>
        object SendCommand(object sender, string command, params string[] args);

        /// <summary>
        /// Executes the specified delegate on the thread that owns the host control's underlying window handle.
        /// </summary>
        /// <param name="method">A delegate that contains a method to be called in the host control's thread context.</param>
        /// <returns>An Object that contains the return value from the delegate being invoked, or null if the delegate has no return value.</returns>
        object Invoke(Delegate method);

        /// <summary>
        /// Executes the specified delegate on the thread that owns the host control's underlying window handle.
        /// </summary>
        /// <param name="method">A delegate that contains a method to be called in the host control's thread context.</param>
        /// <param name="args">An array of objects to pass as arguments to the specified method. This parameter can be null if the method takes no arguments.</param>
        /// <returns>An Object that contains the return value from the delegate being invoked, or null if the delegate has no return value.</returns>
        object Invoke(Delegate method, params object[] args);
    }
}
